package me.szlx.validation;

public class ValidatorFactory {
    public static Validator of(String constraintCodeOrBrief) {
        Assert.constraintNotNull(constraintCodeOrBrief);
        return of(Constraint.of(constraintCodeOrBrief));
    }

    public static Validator of(Constraint constraint) {
        Assert.constraintNotNull(constraint);
        return new SimpleValidator(constraint);
    }

    private static class SimpleValidator implements Validator {
        private final Constraint constraint;

        private SimpleValidator(Constraint constraint) {
            this.constraint = constraint;
        }

        @Override
        public Constraint getConstraint() {
            return constraint;
        }
    }
}
